﻿/*
 * Created by SharpDevelop.
 * User: 김효순
 * Date: 2012-08-29
 * Time: 오후 2:51
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace 문자열
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{
		[DllImport("kernel32.dll")]
		private static extern int lstrlen(string lpString);
		
		public MainForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
		}
		
		void Bt1Click(object sender, EventArgs e)
		{
			int sl = lstrlen(tb1.Text);
			
			tb2.Text = sl.ToString();
		}

        private void button1_Click(object sender, EventArgs e)
        {
            byte[] arr = System.Text.Encoding.GetEncoding("euc-kr").GetBytes(tb1.Text);

            tb2.Text = Convert.ToBase64String(arr);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            byte[] arr = System.Convert.FromBase64String(tb1.Text);

            tb2.Text = System.Text.Encoding.GetEncoding("euc-kr").GetString(arr);
        }
	}
}
